package org.nfIt.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.nfIt.entity.product.ProductSpec;
import org.nfIt.mapper.ProductSpecMapper;
import org.nfIt.service.ProductSpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClossName:ProductSpecServiceImpl
 * Pakage:org.nfIt.service.impl
 * Description
 *
 * @Author L
 * @Create 2024/8/19 22:46
 * @Version 2023.1.3
 */
@Service
public class ProductSpecServiceImpl implements ProductSpecService {

    @Autowired
    private ProductSpecMapper productSpecMapper;
    /**
     * 商品规格查询列表
     * @param page 当前页
     * @param limit 每页记录数
     */
    @Override
    public PageInfo<ProductSpec> findByPage(Integer page, Integer limit) {
        PageHelper.startPage(page,limit);
        List<ProductSpec> list = productSpecMapper.findByPage();
        return new PageInfo(list);
    }

    /**
     * 添加方法
     * @param productSpec 实体
     */
    @Override
    public void save(ProductSpec productSpec) {
        productSpecMapper.save(productSpec);
    }

    /**
     * 修改
     * @param productSpec
     */
    @Override
    public void updateById(ProductSpec productSpec) {
        productSpecMapper.updateById(productSpec);
    }

    /**
     * 删除
     */
    @Override
    public void deleteById(Long id) {
        productSpecMapper.deleteById(id);
    }

    /**
     * 查询所有商品规格
     */
    @Override
    public List<ProductSpec> findAll() {
        return  productSpecMapper.findAll();
    }

}
